﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace LI4
{
    public partial class main : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblDate.Text = DateTime.Now.ToString("D");
            frame1.Attributes["src"] = "center.aspx";
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string username = TextBox1.Text;
            string password = TextBox2.Text;


            Data.Login login = new Data.Login();
            Program.Login = login.autenticar(username, password);

            int estado = Program.Login.Estado;


            if (estado == Business.Login.SUCCESS)
            {
                if (Program.Login.Tipo == Business.Login.CANDIDATO)
                {

                    Session["username"] = Program.Login.Username;
                    Response.Redirect("main2.aspx");

                }
                else if (Program.Login.Tipo == Business.Login.EMPRESA)
                {
                    Session["username"] = Program.Login.Username;
                    Response.Redirect("main2.aspx");
                }
                else
                    Response.Write("<script>alert('Nao tem Permissao')</script>");
            }
            else if (estado == Business.Login.BADLOGIN)
                Response.Write("<script>alert('Login nao existe')</script>");
            else if (estado == Business.Login.BADPASS)
                Response.Write("<script>alert('Password errada')</script>");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            frame1.Attributes["src"] = "EscolhaRegisto.aspx";
        }



        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            frame1.Attributes["src"] = "escolhaPesquisaEmpresa.aspx";
        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {

        }

        protected void LinkButton2_Click1(object sender, EventArgs e)
        {
            frame1.Attributes["src"] = "escolhaPesquisaCandidato.aspx";
        }

        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            frame1.Attributes["src"] = "escolhaPesquisaCurso.aspx";
        }

        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            frame1.Attributes["src"] = "escolhaPesquisaAnuncio.aspx";
        }

    }
}
